package org.halk.es.crawl.controller;

import org.halk.es.crawl.entity.Content;
import org.halk.es.crawl.pojo.content.dto.SearchQueryContentDto;
import org.halk.es.crawl.service.IndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;

/**
 * 索引controller
 *
 * @Author halk
 * @Date 2023/3/3 10:42
 **/
@RestController
public class IndexController {

    @Autowired
    private IndexService indexService;

    @GetMapping("/parse/{keyword}")
    public boolean parseHtml(@PathVariable("keyword") String keyword) throws IOException {
        return this.indexService.parseJdSearchHtml(keyword);
    }

    @PostMapping("/search")
    public List<Content> searchQuery(@RequestBody SearchQueryContentDto pageDto) {
        return this.indexService.searchQuery(pageDto);
    }
}
